{% extends myBundleName ~ ':Layout:layout.html.twig' %}

{% block title %}{{ myTitlePrefix }} Schedule Admin {% endblock %}

{% block content %}
{% include myBundleName ~ ':Admin/Schedule/Search:referee.html.twig' %}
<div class="schedule-list">
    <table border="1" style="max-width: 850px;">
        <tr><th colspan="7">Referee Schedule 2012x - Game Count {{ gameCount }}</th></tr>
        <tr>
            <td>Game</td>
            <td>DOW Time</td>
            <td>Field</td>
            <td>Pool</td>
            <td>Home / Away Teams</td>
            <td>Official Signup</td>
        </tr>
        {% for game in games %}
        <tr id="ref-sched-{{game.num}}" class="game-status-{{game.status}}">
            <td>
                {% if is_granted('ROLE_SUPER_ADMIN')  or 1 %}
                <a href="{{ path('zayso_core_admin_schedule_game_edit', { 'id': game.id })}}">{{ game.getNum() }}</a>
                {% else %}
                {{ game.num }}
                {% endif %}
            </td>
            <td>{{ game_dow(game.date) }} {{ game_time(game.time) }}</td>
            <td>{{ game.fieldDesc      }}</td>
            <td>{{ game.pool           }}</td>
            <td>
                {% for teamRel in game.teams %}
                    {% set itemClass = game_team_class(teamIds,teamRel.team) %}
                    {% if  itemClass %}
                        <span class="{{ itemClass }}">{{ teamRel.team.desc }}</span><br />
                    {% else %}
                        {{ teamRel.team.desc }}<br />
                    {% endif %}
                {% endfor %}
            </td>
            <td><table class="game-officials-list" border="1">
                {% for gamePerson in game.eventPersonsSorted  %}
                {% set person = gamePerson.personz %}
                <tr>
                    <td>
                        {% if is_granted('ROLE_SUPER_ADMIN') %}
                        <a href="{{ path('zayso_core_schedule_referee_assign', { 'id': game.id, 'pos': gamePerson.type }) }}">
                           {{ gamePerson.type }}:</a>
                        {% else %}
                           {{ gamePerson.type }}
                        {% endif %}
                    </td>
                    <td>
                   {% set itemClass = person_org_class(game,person) %}
                   {% if  itemClass %}
                        <span class="{{ itemClass }}">{{ person_org(person) }}</span>
                   {% else %}
                        {{ person_org(person) }}
                   {% endif %}
                    </td>
                    
                    <td>{{ person_ref_badge(person) }}</td>
                    <td>{{ person_age(person) }}</td>
                    <td>
                    {% set itemClass = game_person_class(personIds,person) %}
                    {% if  itemClass %}
                        <span class="{{ itemClass }}">{{ person.personName }}</span>
                    {% else %}
                        {{ person.personName }}
                    {% endif %}
                    </td>
                    {#
                    <td>{{ person_aysoid(person) }}</td>
                    <td><span class="person-vol-issue">{{ person_vol   (person) }}</span></td>#}
                </tr>
                {% endfor %}
            </table></td>
        </tr>
        {% endfor %}       
    </table>
</div>
<style>
.team-hilite      { color: green; }
.person-hilite    { color: green; }
.person-vol-issue { color: red; }
.person-region-issue { color: red; }
.person-area-issue   { color: magenta; }

</style>
{% endblock %}

{% block javascripts %}
    {{ parent() }}
    {% include 'ZaysoCoreBundle:Layout:zaysocore-js.html.twig' %}

<script>

$(document).ready(function() 
{
    // name = schSearch[*][ALL]
    $('input[type=checkbox][name^="refSchSearch["][name$="][ALL]"]').change(Zayso.checkboxAll);
})
</script>
{% endblock %}